//
//  AttachmentManager.m
//
//
//  Created by Ralf on 6/19/15.
//
//

#import "AttachmentManager.h"
#import "AppDelegate.h"

@implementation AttachmentManager

- (ResultSet *)uploadImage:(NSString *)articleId image:(UIImage *)image desc:(NSString *)desc
{
    NSMutableDictionary *params = [NSMutableDictionary new];

    params[@"sessionID"] = [self getSessionID];

    NSData   *dImage = UIImageJPEGRepresentation(image, 0.1);
    NSData   *data   = [dImage base64EncodedDataWithOptions:NSDataBase64Encoding64CharacterLineLength];
    NSString *sImage = [NSString stringWithUTF8String:[data bytes]];
    params[@"articleId"] = articleId;
    params[@"image"]     = sImage;
    params[@"description"]     = desc;
    return [self requestJSON:@"attachment/uploadImage" params:params];
}

@end
